home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume3 / conquer / part06 < prev    next >
Encoding:
Internet Message Format  |  1988-01-23  |  24.4 KB

  1. Path: uunet!tektronix!tekgen!tekred!games-request
  2. From: games-request@tekred.TEK.COM
  3. Newsgroups: comp.sources.games
  4. Subject: v03i075:  conquer - version 2 of the renamed conquest adventure game, Part06/06
  5. Message-ID: <2109@tekred.TEK.COM>
  6. Date: 22 Jan 88 21:35:15 GMT
  7. Sender: billr@tekred.TEK.COM
  8. Lines: 861
  9. Approved: billr@tekred.TEK.COM
  10.  
  11. Submitted by: ihnp4!mhuxd!smile (Ed Barlow)
  12. Comp.sources.games: Volume 3, Issue 75
  13. Archive-name: conquer/Part06
  14.  
  15. #! /bin/sh
  16.  
  17. # This is a shell archive.  Remove anything before this line, then unpack
  18. # it by saving it into a file and typing "sh file".  To overwrite existing
  19. # files, type "sh file -c".  You can also feed this as standard input via
  20. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  21. # will see the following message at the end:
  22. #        "End of archive 6 (of 6)."
  23. # Contents:  data.h io.c
  24. # Wrapped by billr@tekred on Fri Jan 22 13:27:14 1988
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f data.h -a "${1}" != "-c" ; then 
  27.   echo shar: Will not over-write existing file \"data.h\"
  28. else
  29. echo shar: Extracting \"data.h\" \(9490 characters\)
  30. sed "s/^X//" >data.h <<'END_OF_data.h'
  31. X
  32. X/*--------I DO BELIEVE IT IS NECESSARY TO ALTER THIS FILE-------------------*/
  33. X
  34. X#include <curses.h>
  35. X#define FLAT 1        /*1 if world is flat 0 if round - not implemented*/
  36. X/*#define NPCWATER    Can NPC's move on water*/
  37. X
  38. X/*simple contour map definitions*/
  39. X#define WATER     '~'
  40. X#define PEAK     '#'    
  41. X#define MOUNTAIN '^'
  42. X#define HILL     '%'    
  43. X#define CLEAR     '-'
  44. X
  45. X/*racial types*/
  46. X#define GOD     '-'
  47. X#define ORC     'O'
  48. X#define ELF     'E'
  49. X#define DWARF     'D'
  50. X#define LIZARD     'L'
  51. X#define HUMAN     'H'
  52. X#define PIRATE  'P'
  53. X#define BARBARIAN 'B'
  54. X#define NOMAD      'N'
  55. X#define UNKNOWN '?'
  56. X
  57. X/*designations*/
  58. X#define DCITY        'c'
  59. X#define DCAPITOL    'C'
  60. X#define DMINE        'm'
  61. X#define DFARM        'f'
  62. X#define DDEVASTATED    'x'
  63. X#define DGOLDMINE    '$'
  64. X#define DCASTLE        '!'
  65. X#define DNODESIG    '-'
  66. X
  67. X#define GREAT    'G'
  68. X#define FAIR    'F'
  69. X#define RANDOM    'R'
  70. X#define OOPS    'X'
  71. X
  72. X/*vegetation types --  these are legal in designations too*/
  73. X#define VOLCANO 'V'
  74. X#define DESERT     'D'
  75. X#define WASTE      'W'
  76. X#define BARREN     '4'
  77. X#define LT_VEG     '6'    
  78. X#define GOOD     '9'
  79. X#define WOOD     '7'
  80. X#define FORREST '3'
  81. X#define JUNGLE     'J'    
  82. X#define SWAMP     'S'
  83. X#define ICE     'I'    
  84. X#define NONE     '~'
  85. X
  86. X/*Diplomacy Variables*/
  87. X#define JIHAD         7
  88. X#define WAR         6
  89. X#define HOSTILE        5
  90. X#define NEUTRAL        4
  91. X#define FRIENDLY    3
  92. X#define ALLIED         2
  93. X#define CONFEDERACY     1
  94. X#define UNMET        0
  95. X
  96. X/*army status*/
  97. X# define MARCH         1    /*March */
  98. X# define SCOUT        2    /*Scouting--will not engage enemy if possible*/
  99. X# define ATTACK     3    /*Attack anybody (Hostile+) within 2 sectors*/
  100. X# define DEFEND        4    /*Defend */
  101. X# define GARRISON     5    /*Garrison--for a city or Capital*/
  102. X
  103. Xstruct s_sector
  104. X{
  105. X    char  designation;/*designation of sector*/
  106. X    char  altitude;  /*sector altitude */
  107. X    char  vegetation; /*sector vegetation  */
  108. X    short owner;      /*nation id of owner, MAXNTN+? is SPECIAL*/
  109. X    int   people;     /*civilians in sector*/
  110. X    short gold;      /*gold production ability*/
  111. X    short fortress;   /*fortification level (0 to 9)*/
  112. X    short iron;      /*amount of iron produced by sector*/
  113. X};
  114. X#define SOWN     sct[xcurs+xoffset][ycurs+yoffset].owner
  115. X#define XREAL     (xcurs+xoffset)
  116. X#define YREAL     (ycurs+yoffset)
  117. X
  118. X#define SCREEN_X_SIZE    ( (COLS - 21) / 2 )
  119. X#define SCREEN_Y_SIZE    ( LINES - 5 )
  120. X
  121. X#define PASSLTH 7     /*one less than the characters in the password*/
  122. X#define NAMELTH 9     /*one less than the characters in the name*/
  123. X#define LEADERLTH 9   /*one less than the characters in the leader*/
  124. X
  125. X/*IN THE FUTURE ARMIES AND NAVIES SHOULD BE IN THE SAME STRUCTURE (UNITS)
  126. X*units could include cavalry, militia, navies, armies, garrisons, and leaders
  127. X*struct unit
  128. X*{
  129. X*    short unittype
  130. X*    short type1
  131. X*    short type2
  132. X*    short type3
  133. X*    short xloc
  134. X*    short yloc
  135. X*    short smove
  136. X*    short status
  137. X*}
  138. X*/
  139. X
  140. Xstruct navy
  141. X{
  142. X    short warships;
  143. X    short merchant;
  144. X    short xloc;
  145. X    short yloc;
  146. X    short smove;
  147. X};
  148. X
  149. Xstruct army
  150. X{
  151. X    short xloc;
  152. X    short yloc;
  153. X    short smove;
  154. X    int sold; 
  155. X    short stat;
  156. X};
  157. X
  158. Xstruct     nation    /* player nation stats */
  159. X        {
  160. X        char   name[NAMELTH+1];/* name */
  161. X        char   passwd[PASSLTH+1];/* password */
  162. X        char   leader[LEADERLTH+1];/* leader title */
  163. X        char   race;    /* national race (integer--see header.h)*/
  164. X        short  class;    /* national class*/
  165. X        char   location;/* location variable gfr */
  166. X    char   mark;    /* unique mark for nation*/
  167. X        short  capx;    /* capital x coord */
  168. X        short  capy;    /* capital y coord */
  169. X        short  active;    /* activity level of nation, but I am not sure if
  170. X                i have used this variable consistently:
  171. X                 1 if PC NATION, 
  172. X                2+Aggressiveness if NPC, 
  173. X                0 if inactive,
  174. X                999 to represents MONSTER (pirate...)*/
  175. X        short  aplus;    /* attack plus of all soldiers*/
  176. X        short  dplus;    /* attack plus of all soldiers*/
  177. X        short  maxmove;    /* maximum movement of soldiers*/
  178. X        short  repro;    /* reproduction rate of nation*/
  179. X        short  score;    /* score */
  180. X        long   tgold;    /* gold in treasury */
  181. X        long   jewels;    /* raw amount of gold in treasury */
  182. X        long   tmil;    /* total military */
  183. X        long   tciv;    /* total civilians */
  184. X        long   tiron;    /* total real iron in nation*/
  185. X        long   tfood;    /* total food in nation*/
  186. X    long   powers;
  187. X        short  tsctrs;    /* total number sectors */
  188. X        short  tships;    /* number warships */
  189. X    struct army arm[MAXARM];
  190. X    struct navy nvy[MAXNAVY];
  191. X    short  dstatus[MAXNTN+4];    /*diplomatic status*/
  192. X};
  193. X
  194. X#define AXLOC ntn[country].arm[armynum].xloc 
  195. X#define AYLOC ntn[country].arm[armynum].yloc 
  196. X#define AMOVE ntn[country].arm[armynum].smove 
  197. X#define ASOLD ntn[country].arm[armynum].sold 
  198. X#define ASTAT ntn[country].arm[armynum].stat 
  199. X#define NWAR  ntn[country].nvy[nvynum].warships
  200. X#define NMER  ntn[country].nvy[nvynum].merchant
  201. X#define NXLOC ntn[country].nvy[nvynum].xloc 
  202. X#define NYLOC ntn[country].nvy[nvynum].yloc 
  203. X#define NMOVE ntn[country].nvy[nvynum].smove
  204. X
  205. Xextern  struct s_sector sct[MAPX][MAPY];
  206. Xextern  struct nation ntn[MAXNTN+4];
  207. Xextern  short movecost[MAPX][MAPY];
  208. X/*is sector occupied, if MAXNTN+1 2+ armies occupy*/
  209. Xextern    char    occ[ MAPX ][ MAPY ];
  210. X
  211. X/*Movement costs*/
  212. Xextern char *ele;
  213. Xextern char *veg;
  214. Xextern char *numbers;
  215. Xextern char *races[];
  216. Xextern char *Class[];
  217. Xextern char *vegname[];
  218. Xextern char *diploname[];
  219. Xextern char *soldname[];
  220. X
  221. X#define AORN 0
  222. X#define ARMY 1
  223. X#define NAVY 2
  224. X
  225. X#define XASTAT     1
  226. X#define XAMEN     2
  227. X#define XALOC     4
  228. X#define XNLOC     5 
  229. X#define XNASHP     6 
  230. X#define XECNAME    8 
  231. X#define XECPAS     9 
  232. X#define XECMARK    10 
  233. X#define XSADES     11 
  234. X#define XSACIV     12 
  235. X#define XSIFORT    13 
  236. X#define XNAGOLD    14 
  237. X#define XAMOV     15
  238. X#define XNMOV     16 
  239. X#define XSAOWN     17 
  240. X#define EDADJ    18
  241. X#define XNARGOLD 19
  242. X#define XNAIRON 20
  243. X#define INCAPLUS 22
  244. X#define INCDPLUS 23
  245. X#define CHG_MGK 24
  246. X#define DESTRY 25
  247. X
  248. X#define DESTROY fprintf(fexe,"DESTROY \t%d \t%d \t%hd \t0 \t0 \t%s\n",DESTRY,save,country,"null")
  249. X#define CHGMGK fprintf(fexe,"L_MAGIC \t%d \t%hd \t%ld \t%d \t0 \t%s\n",CHG_MGK,country,ntn[country].powers,x,"null")
  250. X#define I_APLUS fprintf(fexe,"INC_APLUS \t%d \t%hd \t0 \t0 \t0 \t%s\n",INCAPLUS,country,"null")
  251. X#define I_DPLUS fprintf(fexe,"INC_DPLUS \t%d \t%hd \t0 \t0 \t0 \t%s\n",INCDPLUS,country,"null")
  252. X#define AADJSTAT fprintf(fexe,"A_STAT \t%d \t%hd \t%d \t%d \t0 \t%s\n",XASTAT,country,armynum,ntn[country].arm[armynum].stat,"null")
  253. X#define AADJMEN  fprintf(fexe,"L_ADJMEN \t%d \t%hd \t%d \t%d \t0 \t%s\n",XAMEN ,country,armynum,ntn[country].arm[armynum].sold,"null")
  254. X#define NADJSHP  fprintf(fexe,"N_ASHP \t%d \t%hd \t%d \t%d \t%d \t%s\n",XNASHP ,country,nvynum,ntn[country].nvy[nvynum].merchant,ntn[country].nvy[nvynum].warships,"null" )
  255. X#define AADJLOC  fprintf(fexe,"A_LOC \t%d \t%hd \t%d \t%d \t%d \t%s\n",XALOC ,country,armynum,ntn[country].arm[armynum].xloc,ntn[country].arm[armynum].yloc,"null")
  256. X#define NADJLOC  fprintf(fexe,"N_LOC \t%d \t%hd \t%d \t%d \t%d \t%s\n",XNLOC ,country,nvynum,ntn[country].nvy[nvynum].xloc,ntn[country].nvy[nvynum].yloc ,"null")
  257. X#define AADJMOV  fprintf(fexe,"A_MOV \t%d \t%hd \t%d \t%d \t0 \t%s\n",XAMOV ,country,armynum,ntn[country].arm[armynum].smove,"null")
  258. X#define NADJMOV  fprintf(fexe,"N_MOV \t%d \t%hd \t%d \t%d \t0 \t%s\n",XNMOV ,country,nvynum,ntn[country].nvy[nvynum].smove,"null")
  259. X#define ECHGNAME fprintf(fexe,"E_CNAME \t%d \t%hd \t0 \t0 \t0 \t%s\n",XECNAME ,country,ntn[country].name)
  260. X#define ECHGPAS  fprintf(fexe,"E_CPAS \t%d \t%hd \t0 \t0 \t0 \t%s\n",XECPAS ,country,crypt(string,SALT))
  261. X#define SADJDES  fprintf(fexe,"S_ADES \t%d \t%hd \t0 \t%d \t%d \t%c\n",XSADES ,country,xcurs+xoffset,ycurs+yoffset,sct[xcurs+xoffset][ycurs+yoffset].designation)
  262. X#define SADJDES2  fprintf(fexe,"S_ADES \t%d \t%hd \t0 \t%d \t%d \t%c\n",XSADES ,country,x,y,sct[x][y].designation)
  263. X#define SADJCIV2  fprintf(fexe,"S_ACIV \t%d \t%hd \t%d \t%d \t%d \t%s\n",XSACIV ,country,sct[i][j].people,i,j,"null")
  264. X#define SADJCIV  fprintf(fexe,"S_ACIV \t%d \t%hd \t%d \t%d \t%d \t%s\n",XSACIV ,country,sct[xcurs+xoffset][ycurs+yoffset].people,xcurs+xoffset,ycurs+yoffset,"null")
  265. X#define INCFORT fprintf(fexe,"SIFORT \t%d \t%hd \t0 \t%d \t%d \t%s\n",XSIFORT ,country,xcurs+xoffset,ycurs+yoffset,"null")
  266. X#define SADJOWN  fprintf(fexe,"S_AOWN \t%d \t%hd \t0 \t%d \t%d \t%s\n",XSAOWN ,country,xcurs+xoffset,ycurs+yoffset,"null")
  267. X#define EADJDIP  fprintf(fexe,"E_ADJ \t%d \t%hd \t%d \t%d \t0 \t%s\n",EDADJ,country,nation,ntn[country].dstatus[nation],"null")
  268. X
  269. X#define    WARRIOR        0x000001
  270. X#define    CAPTAIN        0x000002
  271. X#define    WARLORD        0x000004
  272. X#define    MI_MONST    0x000008
  273. X#define    AV_MONST    0x000010
  274. X#define    MA_MONST    0x000020
  275. X#define    SPY        0x000040
  276. X#define    KNOWALL        0x000080
  277. X#define    DERVISH        0x000100
  278. X#define    DESTROYER    0x000200
  279. X#define    HIDDEN        0x000400
  280. X#define    THE_VOID    0x000800
  281. X#define    ARCHITECT    0x001000
  282. X#define    VAMPIRE        0x002000
  283. X#define    HEALER        0x004000
  284. X#define MINER        0x008000
  285. X#define URBAN        0x010000
  286. X#define STEEL        0x020000
  287. X#define ARCHER        0x040000
  288. X#define CAVALRY        0x080000
  289. X#define BREEDER        0x100000
  290. X
  291. X#define MAXPOWER    21 /* number of powers */
  292. X
  293. X/*my first macro: which will return 1 if the nation has that power*/
  294. X#define magic(NATION,POWER)    ((ntn[NATION].powers&(POWER))!=0)  
  295. X
  296. X#define ONMAP    (x>=0 && y>=0 && x<MAPX && y<MAPY)
  297. X
  298. X#ifndef HILIGHT
  299. X#define standout()        
  300. X#endif
  301. X  
  302. X#ifdef BEEP
  303. X#define beep()        putchar('\007')
  304. X#else
  305. X#define beep()        
  306. X#endif
  307. X  
  308. X#ifdef SRANDOM
  309. X#define rand()      random()
  310. X#define srand(x)    srandom(x)
  311. X#endif 
  312. X
  313. X#define FOODTHRESH 3
  314. X#define GOLDTHRESH 10
  315. X#define JEWELTHRESH 10
  316. X    
  317. X#define SALT "aa"
  318. X
  319. X/*intialize subroutine types*/
  320. Xchar *crypt();
  321. Xvoid exit();
  322. Xint rand();
  323. X
  324. Xextern char *strcpy(), *strncpy(), *strcat(), *strncat();
  325. X
  326. X/*file name definitions */
  327. Xextern    char    *exefile;
  328. Xextern    char    *datafile;
  329. Xextern    char    *msgfile;
  330. Xextern    char    *npcsfile;
  331. Xextern    char    *helpfile;
  332. Xextern    char    *newsfile;
  333. END_OF_data.h
  334. if test 9490 -ne `wc -c <data.h`; then
  335.     echo shar: \"data.h\" unpacked with wrong size!
  336. fi
  337. # end of overwriting check
  338. fi
  339. if test -f io.c -a "${1}" != "-c" ; then 
  340.   echo shar: Will not over-write existing file \"io.c\"
  341. else
  342. echo shar: Extracting \"io.c\" \(12673 characters\)
  343. sed "s/^X//" >io.c <<'END_OF_io.c'
  344. X/*io.c*/
  345. X/*Print and io subroutines for game*/
  346. X
  347. X/*conquer is copyrighted 1986 by Ed Barlow.
  348. X *  I spent a long time writing this code & I hope that you respect this.  
  349. X *  I give permission to alter the code, but not to copy or redistribute
  350. X *  it without my explicit permission.  If you alter the code, 
  351. X *  please document changes and send me a copy, so all can have it.  
  352. X *  This code, to the best of my knowledge works well,  but it is my first
  353. X *  'C' program and should be treated as such.  I disclaim any
  354. X *  responsibility for the codes actions (use at your own risk).  I guess
  355. X *  I am saying "Happy gaming", and am trying not to get sued in the process.
  356. X *                                                Ed
  357. X */
  358. X
  359. X/*include files*/
  360. X#include <ctype.h>
  361. X#include "header.h"
  362. X#include "data.h"
  363. X
  364. X/*Declarations*/
  365. Xextern struct s_sector sct[MAPX][MAPY];
  366. Xextern struct nation ntn[NTOTAL];   /* player nation stats */
  367. X
  368. X/*offset of upper left hand corner*/
  369. Xextern short xoffset;
  370. Xextern short yoffset;
  371. X/*current cursor postion (relative to 00 in upper corner)*/
  372. X/*    position is 2*x,y*/
  373. Xextern short xcurs;
  374. Xextern short ycurs;
  375. X/*redraw map in this turn if redraw is a 1*/
  376. Xextern short redraw;
  377. X/*display state*/
  378. Xextern short hilmode;   /*highlight modes: 0=owned sectors, 1= armies, 2=none*/
  379. Xextern short dismode;   /*display mode: 1=vegetation, 2=desig, 3=contour*/
  380. X/*         4=armies/navies, 5=commodities, 6=fertility, 7=movement*/
  381. X/* nation id of owner*/
  382. Xextern short country;
  383. X
  384. X/*print a sector.altitude map subroutine*/
  385. Xprintele()
  386. X{
  387. X    register int X, Y;
  388. X    printf("doing print of altitude\n");
  389. X    for(Y=0;Y<MAPY;Y++) {
  390. X        for(X=0;X<MAPX;X++) putc(sct[X][Y].altitude,stdout);
  391. X        putc('\n',stdout);
  392. X    }
  393. X}
  394. X
  395. Xpr_ntns()
  396. X{
  397. X    register int X, Y;
  398. X    printf("doing print of nations\n");
  399. X    for(Y=0;Y<MAPY;Y++) {
  400. X        for(X=0;X<MAPX;X++) {
  401. X            if(sct[X][Y].owner==0)
  402. X                putc(sct[X][Y].altitude,stdout);
  403. X            else putc(ntn[sct[X][Y].owner].mark,stdout);
  404. X        }
  405. X        putc('\n',stdout);
  406. X    }
  407. X}
  408. X
  409. X/*print all data--trashes/creates datafile in the process*/
  410. Xwritedata()
  411. X{
  412. X    int fd;
  413. X    printf("\ndoing write of data\n");
  414. X    if((fd = creat(datafile,0666))==-1) {
  415. X        printf("cant open data.  check permissions\n");
  416. X        return;
  417. X    }
  418. X    write(fd,sct,sizeof(sct));
  419. X    write(fd,ntn,sizeof(ntn));
  420. X    close(fd);
  421. X}
  422. X
  423. Xreaddata()
  424. X{
  425. X    int fd;
  426. X    int n_read;
  427. X
  428. X    /*read in existing nation army and navy data*/
  429. X    /*check if file openable*/
  430. X    printf("reading data file\n");
  431. X    if( (fd = open(datafile,0)) < 0 ) {
  432. X        fprintf( stderr, "can not open %s \n", datafile );
  433. X        exit( 1 );
  434. X    }
  435. X    if((n_read=read(fd,sct,sizeof(sct)))==0) printf("EOF\n");
  436. X    else if(n_read==-1) printf("error reading sector data (sct)\n");
  437. X    if(n_read!=sizeof(sct)) {
  438. X        printf( "wrong data format (%d vs. %d)\n",n_read, sizeof(sct) );
  439. X        exit(1);
  440. X    }
  441. X    if((n_read=read(fd,ntn,sizeof(ntn)))==0) printf("EOF\n");
  442. X    else if(n_read==-1) printf("error reading nation data (ntn)\n");
  443. X    if(n_read!=sizeof(ntn)) {
  444. X        printf( "wrong data format (%d vs. %d)\n",n_read, sizeof(ntn) );
  445. X        exit(1);
  446. X    }
  447. X    close(fd);
  448. X    verifydata( __FILE__, __LINE__ );
  449. X
  450. X} /* readdata() */
  451. X
  452. X/*print a map subroutine*/
  453. Xprintveg()
  454. X{
  455. X    register int X, Y;
  456. X    printf("doing print of vegetation\n");
  457. X    for(Y=0;Y<MAPY;Y++) {
  458. X        for(X=0;X<MAPX;X++) putc(sct[X][Y].vegetation,stdout);
  459. X        putc('\n',stdout);
  460. X    }
  461. X}
  462. X
  463. X/*make a map*/
  464. Xmakemap()
  465. X{
  466. X    register int x,y;
  467. X    register int i,j;
  468. X    short armynum,nvynum;
  469. X
  470. X    /*can you see all?*/
  471. X    if((magic(country,KNOWALL)==1)||(country==0)) {
  472. X        for(x=0;x<SCREEN_X_SIZE;x++) {
  473. X            for(y=0;y<(LINES-4);y++) {
  474. X                highlight(x,y);
  475. X                see(x,y);
  476. X            }
  477. X        }
  478. X        if((hilmode==1)||(hilmode==4)||(hilmode==3)) {
  479. X            for(armynum=0;armynum<MAXARM;armynum++) 
  480. X            if((ASOLD>0)&&((AMOVE>0)||(hilmode!=4))){
  481. X                standout();
  482. X                see(AXLOC-xoffset,AYLOC-yoffset);
  483. X            }
  484. X        }
  485. X    }
  486. X    /*see as appropriate?*/
  487. X    else {
  488. X        for(x=0;x<SCREEN_X_SIZE;x++) for(y=0;y<(LINES-4);y++) {
  489. X            if(sct[x+xoffset][y+yoffset].owner==country){
  490. X                for(i=x-LANDSEE;i<=x+LANDSEE;i++){
  491. X                    for(j=y-LANDSEE;j<=y+LANDSEE;j++) {
  492. X                        highlight(i,j);
  493. X                        see(i,j);
  494. X                    }
  495. X                }
  496. X            }
  497. X        }
  498. X        for(nvynum=0;nvynum<MAXNAVY;nvynum++) if(NMER+NWAR>0){
  499. X            for(i=NXLOC-xoffset-NAVYSEE;i<=NXLOC-xoffset+NAVYSEE;i++) for(j=NYLOC-yoffset-NAVYSEE;j<=NYLOC-yoffset+NAVYSEE;j++){
  500. X                highlight(i,j);
  501. X                see(i,j);
  502. X            }
  503. X        }
  504. X        for(armynum=0;armynum<MAXARM;armynum++) if(ASOLD>0){
  505. X            for(i=AXLOC-xoffset-ARMYSEE;i<=AXLOC-xoffset+ARMYSEE;i++) for(j=AYLOC-yoffset-ARMYSEE;j<=AYLOC-yoffset+ARMYSEE;j++) {
  506. X                highlight(i,j);
  507. X                see(i,j);
  508. X            }
  509. X        }
  510. X        /*optimal method of highlighting your armies*/
  511. X        if((hilmode==3)||(hilmode==4)) {
  512. X            for(armynum=0;armynum<MAXARM;armynum++) 
  513. X            if((ASOLD>0)&&((AMOVE>0)||(hilmode==3))){
  514. X                standout();
  515. X                see(AXLOC-xoffset,AYLOC-yoffset);
  516. X            }
  517. X            for(nvynum=0;nvynum<MAXNAVY;nvynum++) 
  518. X            if((NWAR+NMER>0)&&((NMOVE>0)||(hilmode==3))){
  519. X                standout();
  520. X                see(NXLOC-xoffset,NYLOC-yoffset);
  521. X            }
  522. X        }
  523. X    }
  524. X    move(ycurs,2*xcurs);
  525. X}
  526. X
  527. Xnewdisplay()
  528. X{
  529. X    mvaddstr(LINES-4,0,"viewing options:  (d)esignation, (r)ace, (m)ove cost, (p)eople, (D)efense");
  530. X    clrtoeol();
  531. X        mvaddstr(LINES-3,0,"                  (c)ontour, (v)egitation, (i)ron, (n)ation mark, (g)old");
  532. X    clrtoeol();
  533. X    mvaddstr(LINES-2,0,"highlight option: (o)wners, (a)rmy, (y)our Army, (M)ove left, (x)=none");
  534. X    clrtoeol();
  535. X    standout();
  536. X    mvaddstr(LINES-1,0,"what display?:");
  537. X    clrtoeol();
  538. X    move(LINES-1,16);
  539. X    standend();
  540. X    refresh();
  541. X    redraw=TRUE;
  542. X    switch(getch()) {
  543. X    case 'v':    /* vegetation map*/
  544. X        dismode=1;
  545. X        break;
  546. X    case 'd':    /* designations map*/
  547. X        dismode=2;
  548. X        break;
  549. X    case 'c':    /* contour map of world */
  550. X        dismode=3;
  551. X        break;
  552. X    case 'n':    /* nations map*/
  553. X        dismode=4;
  554. X        break;
  555. X    case 'r':    /* race map*/
  556. X        dismode=5;
  557. X        break;
  558. X    case 'm':    /* move cost map*/
  559. X        dismode=7;
  560. X        break;
  561. X    case 'D':
  562. X        dismode=8;
  563. X        break;
  564. X    case 'p':
  565. X        dismode=9;
  566. X        break;
  567. X    case 'g':
  568. X        dismode=10;
  569. X        break;
  570. X    case 'i':
  571. X        dismode=11;
  572. X        break;
  573. X    case 'a':    /* armies hilighted map*/
  574. X        prep();
  575. X        hilmode=1;
  576. X        break;
  577. X    case 'o':    /* owners hilighted map*/
  578. X        hilmode=0;
  579. X        break;
  580. X    case 'x':    /*no highlighting*/
  581. X        hilmode=2;
  582. X        break;
  583. X    case 'y':    /* your armies hilighted map*/
  584. X        prep();
  585. X        hilmode=3;
  586. X        break;
  587. X    case 'M':    /* your armies with moves left hilighted map*/
  588. X        prep();
  589. X        hilmode=4;
  590. X        break;
  591. X    default:
  592. X        beep();
  593. X        redraw=FALSE;
  594. X    }
  595. X    makebottom();
  596. X}
  597. X
  598. X/*see what is in xy as per display mode*/
  599. Xsee(x,y)
  600. X{
  601. X    int armbonus;
  602. X    if((x<0)||(y<0)||(x>COLS-21)||(y>=LINES-4)) return;
  603. X    if(((y+yoffset)<MAPY)&&((x+xoffset)<MAPX)) {
  604. X
  605. X        if((dismode>7)&&(country!=sct[x+xoffset][y+yoffset].owner)
  606. X        &&(magic(sct[x+xoffset][y+yoffset].owner,THE_VOID)==1)
  607. X        &&(country!=0)) {
  608. X            standout();
  609. X            mvaddch(y,2*x,' ');
  610. X            standend();
  611. X        }
  612. X        else {
  613. X            switch(dismode){
  614. X            case 1: /*vegetation*/
  615. X                mvaddch(y,2*x,sct[x+xoffset][y+yoffset].vegetation);
  616. X                break;
  617. X            case 2: /*designation*/
  618. X                if(sct[x+xoffset][y+yoffset].owner==0){
  619. X                    if(isdigit(sct[x+xoffset][y+yoffset].vegetation)!=0) mvaddch(y,2*x,sct[x+xoffset][y+yoffset].altitude);
  620. X                    else mvaddch(y,2*x,sct[x+xoffset][y+yoffset].vegetation);
  621. X                }
  622. X                else if((country==0)
  623. X                ||(sct[x+xoffset][y+yoffset].owner==country)) 
  624. X                mvaddch(y,2*x,sct[x+xoffset][y+yoffset].designation);
  625. X                else mvaddch(y,2*x,ntn[sct[x+xoffset][y+yoffset].owner].mark);
  626. X                break;
  627. X            case 3: /*contour*/
  628. X                mvaddch(y,2*x,sct[x+xoffset][y+yoffset].altitude);
  629. X                break;
  630. X            case 4: /*ownership*/
  631. X                if(sct[x+xoffset][y+yoffset].owner==0)
  632. X                    mvaddch(y,2*x,sct[x+xoffset][y+yoffset].altitude);
  633. X                else mvaddch(y,2*x,ntn[sct[x+xoffset][y+yoffset].owner].mark);
  634. X                break;
  635. X            case 5: /*race*/
  636. X                if(sct[x+xoffset][y+yoffset].owner==0)
  637. X                    mvaddch(y,2*x,sct[x+xoffset][y+yoffset].altitude);
  638. X                else mvaddch(y,2*x,ntn[sct[x+xoffset][y+yoffset].owner].race);
  639. X                break;
  640. X            case 7:    /*movement cost map*/
  641. X                if(movecost[x+xoffset][y+yoffset]>=0) mvprintw(y,2*x,"%d",movecost[x+xoffset][y+yoffset]);
  642. X                else if(sct[x+xoffset][y+yoffset].altitude==WATER)
  643. X                    mvaddch(y,2*x,WATER);
  644. X                else
  645. X                    mvaddch(y,2*x,'X');
  646. X                break;
  647. X            case 8:   /*Defence*/
  648. X                if (sct[x+xoffset][y+yoffset].altitude==WATER)
  649. X                    mvaddch(y,2*x,WATER);
  650. X                else if (movecost[x+xoffset][y+yoffset]<0)
  651. X                    mvaddch(y,2*x,'*');
  652. X                else {
  653. X
  654. X                    /*Racial combat bonus due to terrain (the faster you move the better)*/
  655. X                    armbonus=0;
  656. X                    armbonus+=5*(9-movecost[x+xoffset][y+yoffset]);
  657. X
  658. X                    if(sct[x+xoffset][y+yoffset].altitude==MOUNTAIN) armbonus+=40;
  659. X                    else if(sct[x+xoffset][y+yoffset].altitude==HILL) armbonus+=20;
  660. X
  661. X                    if(sct[x+xoffset][y+yoffset].vegetation==JUNGLE)
  662. X                        armbonus+=30;
  663. X                    else if(sct[x+xoffset][y+yoffset].vegetation==FORREST)
  664. X                        armbonus+=20;
  665. X                    else if(sct[x+xoffset][y+yoffset].vegetation==WOOD)
  666. X                        armbonus+=10;
  667. X
  668. X            if((sct[x+xoffset][y+yoffset].designation==DCASTLE)
  669. X            ||(sct[x+xoffset][y+yoffset].designation==DCITY)
  670. X            ||(sct[x+xoffset][y+yoffset].designation==DCAPITOL))
  671. X                        armbonus+=8*sct[x+xoffset][y+yoffset].fortress;
  672. X
  673. X                    mvprintw(y,2*x,"%d",armbonus/20);
  674. X                }
  675. X                break;
  676. X            case 9:   /*People*/
  677. X                if (sct[x+xoffset][y+yoffset].altitude==WATER)
  678. X                    mvaddch(y,2*x,WATER);
  679. X                else if (sct[x+xoffset][y+yoffset].people>=1000)
  680. X                    mvaddch(y,2*x,'+');
  681. X                else if (sct[x+xoffset][y+yoffset].people>=450)
  682. X                    mvaddch(y,2*x,'>');
  683. X                else if (sct[x+xoffset][y+yoffset].people==0)
  684. X                    mvaddch(y,2*x,'0');
  685. X                else
  686. X                    mvprintw(y,2*x,"%d",1+sct[x+xoffset][y+yoffset].people/50);
  687. X                break;
  688. X            case 10:  /*Gold*/
  689. X                if (sct[x+xoffset][y+yoffset].altitude==WATER)
  690. X                    mvaddch(y,2*x,WATER);
  691. X                else if(isdigit(sct[x+xoffset][y+yoffset].vegetation)==0) 
  692. X                    mvaddch(y,2*x,'X');
  693. X                else if((sct[x+xoffset][y+yoffset].owner!=0)
  694. X                &&(country!=0)
  695. X                &&(sct[x+xoffset][y+yoffset].owner!=country))
  696. X                    mvaddch(y,2*x,'?');
  697. X                else if(sct[x+xoffset][y+yoffset].gold>=10)
  698. X                    mvaddch(y,2*x,'+');
  699. X                else
  700. X                    mvprintw(y,2*x,"%d",sct[x+xoffset][y+yoffset].gold);
  701. X                break;
  702. X            case 11:  /*Iron*/
  703. X                if (sct[x+xoffset][y+yoffset].altitude==WATER)
  704. X                    mvaddch(y,2*x,WATER);
  705. X                else if(isdigit(sct[x+xoffset][y+yoffset].vegetation)==0) 
  706. X                    mvaddch(y,2*x,'X');
  707. X                else if((sct[x+xoffset][y+yoffset].owner!=0)
  708. X                &&(country!=0)
  709. X                &&(sct[x+xoffset][y+yoffset].owner!=country))
  710. X                    mvaddch(y,2*x,'?');
  711. X                else if (sct[x+xoffset][y+yoffset].iron>=10)
  712. X                    mvaddch(y,2*x,'+');
  713. X                else
  714. X                    mvprintw(y,2*x,"%d",sct[x+xoffset][y+yoffset].iron);
  715. X                break;
  716. X            default:
  717. X                break;
  718. X            }
  719. X        }
  720. X    }
  721. X    else mvaddch(y,2*x,' ');
  722. X    standend();
  723. X}
  724. X
  725. X/*highlight what is in xy as per highlight mode*/
  726. Xhighlight(x,y)
  727. X{
  728. X    if((x<0)||(y<0)||(x>COLS-21)||(y>=LINES-4)) return;
  729. X    if(((y+yoffset)<MAPY)&&((x+xoffset)<MAPX)) {
  730. X        switch(hilmode){
  731. X        case 0: /*ownership*/
  732. X            if(country==0) {
  733. X                if(sct[x+xoffset][y+yoffset].owner>0)
  734. X                    standout();
  735. X            }
  736. X            else if(sct[x+xoffset][y+yoffset].owner==country)
  737. X                standout();
  738. X            break;
  739. X        case 1: /*army map*/
  740. X            if(occ[x+xoffset][y+yoffset]!=0) standout();
  741. X            break;
  742. X        default:
  743. X            break;
  744. X        }
  745. X    }
  746. X}
  747. X
  748. X/* check if cursor is out of bounds*/
  749. Xcoffmap()
  750. X{
  751. X    if((xcurs<1)||(ycurs<1)||(xcurs>=SCREEN_X_SIZE)
  752. X    ||((ycurs>=SCREEN_Y_SIZE))||((XREAL)>=MAPX)
  753. X    ||((YREAL)>=MAPY)) offmap();
  754. X   
  755. X    /*update map*/
  756. X    if(redraw==TRUE) {
  757. X        clear();
  758. X        makemap(); /* update map*/
  759. X        makebottom();
  760. X        redraw=FALSE;
  761. X    }
  762. X    move(ycurs,2*xcurs);
  763. X    makeside();  /*update side*/
  764. X    move(ycurs,2*xcurs);
  765. X    refresh();
  766. X}
  767. X
  768. Xoffmap()
  769. X{
  770. X    redraw=FALSE;
  771. X    /*set offset offsets can not be < 0*/
  772. X    if(xcurs<1){
  773. X        if(XREAL<=0) {
  774. X            xoffset=0;
  775. X            xcurs=0;
  776. X        }
  777. X        else {
  778. X            redraw=TRUE;
  779. X            xoffset-=15;
  780. X            xcurs+=15;
  781. X        }
  782. X    }
  783. X    else if(xcurs >= (COLS-22)/2){
  784. X        if(XREAL<MAPX) {
  785. X            redraw=TRUE;
  786. X            xoffset+=15;
  787. X            xcurs-=15;
  788. X        }
  789. X    }
  790. X    if(XREAL>=MAPX) xcurs=MAPX-1-xoffset;
  791. X    if(xoffset<0) xoffset=0;
  792. X    if(xcurs<0) xcurs=0;
  793. X    else if(xcurs >= (COLS-22)/2) {
  794. X        redraw=TRUE;
  795. X        xoffset+=15;
  796. X        xcurs-=15;
  797. X    }
  798. X
  799. X    if(ycurs<1){
  800. X        if(YREAL<=0) {
  801. X            yoffset=0;
  802. X            ycurs=0;
  803. X        }
  804. X        else {
  805. X            redraw=TRUE;
  806. X            ycurs+=15;
  807. X            yoffset-=15;
  808. X        }
  809. X    }
  810. X    else if(ycurs >= SCREEN_Y_SIZE){
  811. X        if(YREAL<MAPY) {
  812. X            redraw=TRUE;
  813. X            yoffset+=15;
  814. X            ycurs-=15;
  815. X        }
  816. X    }
  817. X    if(YREAL>=MAPY) ycurs=MAPY-1-yoffset;
  818. X    if(yoffset<0) yoffset=0;
  819. X    if(ycurs<0) ycurs=0;
  820. X    else if(ycurs >= SCREEN_Y_SIZE) {
  821. X        redraw=TRUE;
  822. X        yoffset+=15;
  823. X        ycurs-=15;
  824. X    }
  825. X}
  826. X
  827. Xprintscore()
  828. X{
  829. X     int i;
  830. X     int nationid;        /*current nation id */
  831. X     printf("id    race    class    score    gold    militia    people    sectors    name\n");
  832. X     for (nationid=1; nationid<MAXNTN; nationid++) {
  833. X         if(ntn[nationid].active==0) 
  834. X             continue;
  835. X         printf("%d",nationid);
  836. X         for(i=1;i<8;i++)
  837. X             if(ntn[nationid].race==*(races+i)[0])
  838. X                 printf("    %s",*(races+i));
  839. X         if(ntn[nationid].active>=2) printf("    NPC");
  840. X         else printf("    %s",*(Class+ntn[nationid].class));
  841. X         printf("    %d    %d    %d    %d    %d",
  842. X             ntn[nationid].score ,ntn[nationid].tgold
  843. X             ,ntn[nationid].tmil ,ntn[nationid].tciv
  844. X             ,ntn[nationid].tsctrs );
  845. X         printf("    %s\n",ntn[nationid].name);
  846. X     }
  847. X}
  848. END_OF_io.c
  849. if test 12673 -ne `wc -c <io.c`; then
  850.     echo shar: \"io.c\" unpacked with wrong size!
  851. fi
  852. # end of overwriting check
  853. fi
  854. echo shar: End of archive 6 \(of 6\).
  855. cp /dev/null ark6isdone
  856. MISSING=""
  857. for I in 1 2 3 4 5 6 ; do
  858.     if test ! -f ark${I}isdone ; then
  859.     MISSING="${MISSING} ${I}"
  860.     fi
  861. done
  862. if test "${MISSING}" = "" ; then
  863.     echo You have unpacked all 6 archives.
  864.     rm -f ark[1-9]isdone
  865. else
  866.     echo You still need to unpack the following archives:
  867.     echo "        " ${MISSING}
  868. fi
  869. ##  End of shell archive.
  870. exit 0
  871.